package com.videoweb.mapper;

import com.videoweb.entity.VideoComment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.videoweb.entity.dto.VideoCommentDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lmr
 * @since 2025-05-17
 */
@Mapper
public interface VideoCommentMapper extends BaseMapper<VideoComment> {

    public List<VideoCommentDTO> getVideoComment(Long videoId);


//    由于视图不保证 ORDER BY 的执行，最佳实践是在最终查询视图的时候使用 ORDER BY 来控制输出顺序
    @Select("SELECT * FROM comments_view WHERE video_id = #{videoId} ORDER BY created_at DESC;")
    public List<VideoCommentDTO> getVideoCommentByVideoId(Long videoId);

}
